home *** CD-ROM | disk | FTP | other *** search
- /*
- Mouse module class specification.
-
- This is the source file that contains the actual source to the
- routines used to access a mouse pointing device.
-
- Library : mycpp.lib
- */
-
- static char MyMou_Id[] = "mymou.cpp 1.10 05/22/91";
- /*
- Version notes :
- 1.00 - Original creation / release. ( 2-13-91 CW )
- 1.10 - Added enumeration for button specifier. ( 5-22-91 CW )
- */
-
-
- #include <dos.h>
- #include "mymou.h"
-
- /* ------------------------------------------------------------------ */
- void
- myMouse::poll_mouse(){
- union REGS mousreg;
-
- mousreg.x.ax = m1;
- mousreg.x.bx = m2;
- mousreg.x.cx = m3;
- mousreg.x.dx = m4;
- int86(0x33, &mousreg, &mousreg); /* mouse interrupt */
-
- m1 = mousreg.x.ax;
- m2 = mousreg.x.bx;
- m3 = mousreg.x.cx;
- m4 = mousreg.x.dx;
- };
-
- /* .................................................................. */
- void
- myMouse::show(){
- if( !status ){
- m1 = 1;
- poll_mouse();
- status = 1;
- }
- }
-
- /* .................................................................. */
- void
- myMouse::hide(){
- if( status ){
- m1 = 2;
- poll_mouse();
- status = 0;
- }
- }
-
- /* .................................................................. */
- int
- myMouse::pressed( ButtonType button ){
- m1 = 5;
- m2 = (int)button;
-
- poll_mouse();
-
- button_s = m1;
- count = m2;
- xp_pos = m3;
- yp_pos = m4;
-
- return( count );
- }
-
- /* .................................................................. */
- int
- myMouse::released( ButtonType button ){
- m1 = 6;
- m2 = (int)button;
-
- poll_mouse();
-
- button_s = m1;
- count = m2;
- xr_pos = m3;
- yr_pos = m4;
-
- return( count );
- }
-
- /* .................................................................. */
- void
- myMouse::xlimits( int low, int high ){
- m1 = 7;
- m3 = low * 8;
- m4 = high * 8;
- poll_mouse();
- }
-
- /* .................................................................. */
- void
- myMouse::ylimits( int low, int high ){
- m1 = 8;
- m3 = low * 8;
- m4 = high * 8;
- poll_mouse();
- }
-
-
- /* ================================================================== */
-
-
- #ifdef debug_mouse
-
-
- #include <stdio.h>
- #include <conio.h>
-
- main(){
- int done = 0;
- myMouse aMouse;
-
- aMouse.show();
- while( !done ){
- if( aMouse.pressed( LEFT_BUTTON )){
- aMouse.hide();
- printf( "pressed : x = %d, y = %d\n",
- aMouse.xpress(), aMouse.ypress() );
- aMouse.show();
- }
- if( aMouse.released( RIGHT_BUTTON )){
- aMouse.hide();
- printf( "released : x = %d, y = %d\n",
- aMouse.xrelease(), aMouse.yrelease() );
- aMouse.show();
- aMouse.xlimits( 0, 79 );
- aMouse.ylimits( 0, 24 );
- }
- if( aMouse.released( MIDDLE_BUTTON )){
- aMouse.hide();
- printf( "middle : x = %d, y = %d\n",
- aMouse.xrelease(), aMouse.yrelease() );
- aMouse.show();
- aMouse.xlimits( 5, 20 );
- aMouse.ylimits( 5, 10 );
- }
-
- if( kbhit() ){
- done = 1;
- if( !getch() ) // empty the keyboard buffer.
- getch();
- }
- }
-
- return( 0 );
- }
-
- #endif
-